function genParameter(id, value) {
	return $("<input type='hidden' name='"+id+"' value='"+value+"' />");
}

function transmitToUrlWithParams(url, params) {
	var form = $("#transmitForm").attr("action",url).empty();
	if(form.html() == null) {
		form.remove();
		var formNew = '<form id="transmitForm" method="post" action="/xjzp/commQryTransmit.do"></form>';
		$("body").append($(formNew));
		form = $("#transmitForm").attr("action",url).empty();
	}
	$(params).each(function(i, u) {
		form.append(genParameter(u['id'], u['value']));
	});
	$(form)[0].submit();
}

function transmitToBaseUrlWithParams(params) {
	var form = $("#transmitForm").empty();
	if(form.html() == null) {
		form.remove();
		var formNew = '<form id="transmitForm" method="post" action="/xjzp/commQryTransmit.do"></form>';
		$("body").append($(formNew));
		form = $("#transmitForm").attr("action",url).empty();
	}
	$(params).each(function(i, u) {
		form.append(genParameter(u['id'], u['value']));
	});
	$(form)[0].submit();
}

function getPopWindow() {
	return $("#window_commQry div#mainDivInPopWindow");
}

function openPopWindow() {
	popShow_commQry();
}

function closePopWindow() {
	popClose_commQry();
}

function emptyPopWindow() {
	getPopWindow().empty();
}

function createColumnMenu(datagrdId){
	var tmenu = $('<div id="tmenu" style="width:100px;"></div>').appendTo('body');
	var fields = $('#' + datagrdId).datagrid('getColumnFields');
	for(var i=0; i<fields.length; i++){
		var title = $('#' + datagrdId).datagrid('getColumnOption', fields[i]).title;
		$('<div iconCls="icon-ok" id="tmenu_' + fields[i] + '"/>').html(title).appendTo(tmenu);
	}
	tmenu.menu({
		onClick: function(item){
			if (item.iconCls=='icon-ok'){
				$('#' + datagrdId).datagrid('hideColumn', item.id.replace('tmenu_', ''));
				tmenu.menu('setIcon', {
					target: item.target,
					iconCls: 'icon-empty'
				});
			} else {
				$('#' + datagrdId).datagrid('showColumn', item.id.replace('tmenu_', ''));
				tmenu.menu('setIcon', {
					target: item.target,
					iconCls: 'icon-ok'
				});
			}
		}
	});
}
